/**
  **************************************************************************
  * @file     at32f403a_407_board.h
  * @version  v2.1.0
  * @date     2022-06-09
  * @brief    header file for at-start board. set of firmware functions to
  *           manage leds and push-button. initialize delay function.
  **************************************************************************
  *                       Copyright notice & Disclaimer
  *
  * The software Board Support Package (BSP) that is made available to
  * download from Artery official website is the copyrighted work of Artery.
  * Artery authorizes customers to use, copy, and distribute the BSP
  * software and its related documentation for the purpose of design and
  * development in conjunction with Artery microcontrollers. Use of the
  * software is governed by this copyright notice and the following disclaimer.
  *
  * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  *
  **************************************************************************
  */

#ifndef __AT32F403A_407_BOARD_H
#define __AT32F403A_407_BOARD_H

#ifdef __cplusplus
extern "C" {
#endif

#include "at32f403a_407.h"

#include <stdio.h>

/** @addtogroup AT32F403A_407_board
  * @{
  */

/** @addtogroup BOARD
  * @{
  */
/**
 * @brief ST7789V Dimensions
 * 
 */
#define MY_DISP_HOR_RES     240
#define MY_DISP_VER_RES     240
/** @defgroup BOARD_pins_definition
  * @{
  */
	/* st7789 GPIO struct */
#define ST7789_RES_PIN 	GPIO_PINS_6
#define ST7789_RES_PORT GPIOA

#define ST7789_DC_PIN 	GPIO_PINS_4
#define ST7789_DC_PORT 	GPIOA

#define ST7789_CS_PIN 	GPIO_PINS_0
#define ST7789_CS_PORT 	GPIOB

#define ST7789_BLK_PIN 	GPIO_PINS_1
#define ST7789_BLK_PORT GPIOB



#if !defined (AT_START_F403A_V1)&& !defined (AT_START_F407_V1)
#error "please select first the board at-start device used in your application (in at32f403a_407_board.h file)"
#endif

/*
 * Board frequencies.
 */
#define CPU_FREQ       240000000L

#define SYSTICK_1MS_TICKS    ( CPU_FREQ / 1000 )          //1ms
#define SYSTICK_uS_PER_TICK  (1000L / SYSTICK_1MS_TICKS )


/**
  * @}
  */

/** @defgroup BOARD_exported_functions
  * @{
  */

/******************** functions ********************/
void at32_board_init(void);
void printf_xmutex_init (void);
void dbg_printf(const char* format, ...);

void IncTick(void);
/* delay function */
uint64_t getus(void);
uint32_t getms(void);
void delay_us(uint32_t nus);
void delay_ms(uint16_t nms);
void delay_sec(uint16_t sec);
/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif

